
registerJQueryFunction(function(selector){

		/**
		 * Turns textboxes(either input or textarea) to autocomplete boxes.
		 */
		selector('input[autocomplete_action]').each(function(){
				var input=$(this);
				var controller_method=input.controllerAndMethod('autocomplete_action');
				var controller=controller_method[0];
				var method=controller_method[1];
				var sourceFetcher=function(searchString,callback){
					ajaxRequest(controller,method,$.extend(input.collectExtraArgs(),searchString),callback);
				};
				if(input.is('[multi_complete]')){
					input.multi_complete({
							source:sourceFetcher,
							pattern:input.attr('multi_complete')=='default' ? '(\\w|\\d|[.-])+$' : input.attr('multi_complete'),
							padright:input.attr('multi_complete_padright')
					});
				}else{
					input.combobox({
							source:sourceFetcher,
							freetext:input.attr('free_text')
					});
				}
		});
});
